﻿using System.Collections.Generic;

namespace IntellectShop.Web2.Hardware.ViewModels
{
	public class CartViewModel
	{
		public List<Common.CartItem> CartItems { get; set; }

		public int CartCount
		{
			get
			{
				int result = 0;
				foreach (Common.CartItem item in this.CartItems)
				{
					result += item.Count;
				}

				return result;
			}
		}

		public Common.Money CartTotal
		{
			get
			{
				Common.Money result = new Common.Money { Amount = 0, Currency = Common.Currency.RUB };
				foreach (Common.CartItem item in this.CartItems)
				{
					result += item.Commodity.Price * item.Count;
				}

				return result;
			}
		}

		public CartViewModel()
		{
			this.CartItems = new List<Common.CartItem>();
		}
	}
}